Skip to content

Feat/add rt support#1266

Open
h3adex wants to merge 9 commits intostackitcloud:mainfrom
h3adex:feat/add-rt-support
Open

Feat/add rt support#1266
h3adex wants to merge 9 commits intostackitcloud:mainfrom
h3adex:feat/add-rt-support

Conversation

@h3adex
Copy link
Contributor

@h3adex h3adex commented Feb 6, 2026

Description

reopened #1023

Checklist

  • Issue was linked above
  • Code format was applied: make fmt
  • Examples were added / adjusted (see e.g. here)
  • Docs are up-to-date: make generate-docs (will be checked by CI)
  • Unit tests got implemented or updated
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

@h3adex h3adex requested a review from a team as a code owner February 6, 2026 10:13
@github-actions
Copy link

This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it.

@h3adex h3adex force-pushed the feat/add-rt-support branch from 2d82ab3 to d4e9329 Compare March 2, 2026 15:44
@h3adex h3adex force-pushed the feat/add-rt-support branch from d4e9329 to 4d50a2b Compare March 9, 2026 15:27
@h3adex h3adex requested review from marceljk and rubenhoenle March 9, 2026 15:28
Description: utils.Ptr(testRoutingTableDescription),
SystemRoutes: testSystemRoutesFlag,
DynamicRoutes: testDynamicRoutesFlag,
Labels: utils.Ptr(*testLabels),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified

Suggested change
Labels: utils.Ptr(*testLabels),
Labels: testLabels,

Args: args.SingleArg(routingTableIdArg, utils.ValidateUUID),
Example: examples.Build(
examples.NewExample(
`Deletes a a routing-table`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`Deletes a a routing-table`,
`Delete a routing-table with ID "xxx"`,

description: "invalid routing-table ID - empty",
argValues: []string{testRoutingTableId},
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues[routingTableIdArg] = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is failing because the flag routingTableIdArg doesn't exist. the routing-table id is actually set here in the argValues.

}

// Next Hop validation logic
switch strings.ToLower(*model.NextHopType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would set the type of NextHopType to string instead *string. The flag is marked as required so it should be always set. When it's set to a pointer string, it could more likely result somewhere in a nil pointer. With the string type we can prevent this.


// Next Hop validation logic
switch strings.ToLower(*model.NextHopType) {
case "internet", "blackhole":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add some consts for the different nexthopeTypes instead of writing them all as plain strings. this can prevent future issues if somewhere is a typo

Comment on lines +250 to +276
if len(routes) == 0 {
return fmt.Errorf("create routes response is empty")
}

return p.OutputResult(outputFormat, routes, func() error {
table := tables.NewTable()
table.SetHeader("ID", "DESTINATION TYPE", "DESTINATION VALUE", "NEXTHOP TYPE", "NEXTHOP VALUE", "LABELS", "CREATED AT", "UPDATED AT")
for _, route := range routes {
routeDetails := routeUtils.ExtractRouteDetails(route)

table.AddRow(
utils.PtrString(route.Id),
routeDetails.DestType,
routeDetails.DestValue,
routeDetails.HopType,
routeDetails.HopValue,
routeDetails.Labels,
routeDetails.CreatedAt,
routeDetails.UpdatedAt,
)
}
err := table.Display(p)
if err != nil {
return fmt.Errorf("render table: %w", err)
}
return nil
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as mentioned by Ruben in the routingtable create command, we usually don't print a table in the create command. Instead a small info message is enough, e.g. "Created route with ID xxx in routing table yyy"

isValid: true,
},
{
description: "argument value missing",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command actually doesn't support arguments. So if the argument would be really missing, it should pass

Suggested change
description: "argument value missing",
description: "argument value is empty string",

return err
}

prompt := fmt.Sprintf("Are you sure you want to delete the route %q in routing-table %q for network-area-id %q?", model.RouteID, model.RoutingTableId, model.OrganizationId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
prompt := fmt.Sprintf("Are you sure you want to delete the route %q in routing-table %q for network-area-id %q?", model.RouteID, model.RoutingTableId, model.OrganizationId)
prompt := fmt.Sprintf("Are you sure you want to delete the route %q in routing-table %q for network area id %q?", model.RouteID, model.RoutingTableId, model. NetworkAreaId)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants